home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7925 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.7 KB  |  45 lines

  1. Newsgroups: comp.lang.c
  2. Path: undergrad.math.uwaterloo.ca!clgonsal
  3. From: clgonsal@undergrad.math.uwaterloo.ca (Carl Laurence Gonsalves)
  4. Subject: Re: Please Please Help! - pointer notation
  5. Sender: news@undergrad.math.uwaterloo.ca (news spool owner)
  6. Message-ID: <DnJq4C.pA4@undergrad.math.uwaterloo.ca>
  7. Date: Thu, 29 Feb 1996 16:36:12 GMT
  8. References: <4gnlv9$1fh@news.mistral.co.uk>
  9. Nntp-Posting-Host: lhopital.uwaterloo.ca
  10. Organization: University of Waterloo
  11.  
  12. In article <4gnlv9$1fh@news.mistral.co.uk>,
  13. Mike Barnard <mikebarnard@mistral.co.uk> wrote:
  14. >Sometimes when prototyping a function the function name is pre-fixed
  15. >by an asterisk. Why? What does it mean? This is a quote from the
  16. >pointer tutorial text by Ted Jensen...
  17.  
  18. A "*" before a function name the way you describe means that it returns a
  19. pointer. ie:
  20.  
  21. char *Foo( void );
  22.  
  23. Foo is a function which returns a pointer to a char, or a "char *".
  24. Remeber, the above means the same as:
  25.  
  26. char* Foo( void );
  27.  
  28. Which might be a little bit easier to understand. (The reason people tend
  29. to put the space before the * rather than after has to do with the way *'s
  30. are "bound" to variable names. Of course, this doesn't apply to functions,
  31. but many people use the same spacing just to be consistent I guess...)
  32.  
  33. >Putting an asterisk before a variable name declares it as a pointer
  34. >variable. Putting one before the variable in use means you want to
  35. >access the data pointed to. Why is there sometimes an asterisk AFTER a
  36. >variable?
  37.  
  38. Because you want to multiply it with something?
  39.  
  40. -- 
  41.         Carl Laurence Gonsalves - clgonsal@undergrad.math.uwaterloo.ca
  42.                    Computer Science, University of Waterloo
  43.                http://www.undergrad.math.uwaterloo.ca/~clgonsal/
  44.                    http://www.csclub.uwaterloo.ca/~clgonsal/
  45.